#include<bits/stdc++.h>
using namespace std;
int n, m, ans;
int a[100][100];
int d[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
int gkd(){
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			int t1 = 0, t2 = 0;
			for(int z = 0; z < 4; z++){
				int x = d[z][0] + i;
				int y = d[z][1] + j;
				if(a[x][y] == 1) t1++;
				else if(a[x][y] == 2)t2++;
			}
			if(a[i][j] == 1 && t1 > 1) return 0;
			if(a[i][j] == 2 && t2 > 1) return 0;
		}
	}
	for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cout<<a[i][j]<<" ";
        }
        cout<<"\n";
	}
	cout<<"\n";
	cout<<"\n";
	return 1;
}
void dfs(int x, int y){
	if(x == n + 1){
		ans += gkd();
		return;
	}
	for(int i = 1; i <= 2; ++i){
		a[x][y] = i;
		int dx = x, dy = y;
		if(dy == m)
			dx++, dy = 1;
		else dy++;
		dfs(dx, dy);
	}
}
int main()
{
	for(n = 1; n <= 5; ++n){
		for(m = 1; m <= n; ++m){
			memset(a, 0, sizeof a);
			ans = 0;
			dfs(1, 1);
			cout<<ans<<'\n';
		}
		puts("");
	}
 }
